package com.peas.platform.module.icims.base.auth.api;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Api(tags = "自定义接口-验证码")
@RestController
@RequestMapping("/api/v1/customCaptcha")
@Slf4j
public class CustomCaptchaController {

    @Resource
    private HttpServletRequest request;

    /*
    @Resource(name = "captchaProducer")
    private Producer captchaProducer;

    @Resource(name = "captchaProducerMath")
    private Producer captchaProducerMath;

    @SneakyThrows
    @ApiOperation(value = "生成验证码")
    @GetMapping(value = "/captchaImage")
    public ResponseDto<CaptchaResp> captchaImage(String type) {
        HttpSession session = request.getSession();
        CaptchaResp resp = new CaptchaResp();
        String uuid = IdUtil.simpleUUID();
        resp.setUuid(uuid);
        session.setAttribute("uuid", uuid);
        try {
            // 定义图形验证码的长和宽
            GifCaptcha captcha = CaptchaUtil.createGifCaptcha(120, 40);
            // 图形验证码写出，可以写出到文件，也可以写出到流
            String code = captcha.getCode();
            session.setAttribute("code", code);
            InputStream is = new ByteArrayInputStream(captcha.getImageBytes());
            resp.setImg(Base64.encode(is));
            resp.setCaptchaEnabled(true);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            resp.setCaptchaEnabled(false);
        }
        return ResponseDto.getSuccessResponseDto(resp);
    }
    */

}
